﻿using Bible.Core.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace Bible.Core.Model
{
    [DataContract]
    public class Book : IBook
    {
        private readonly IList<IChapter> _chapters;
        private string _title;

        public Book()
            : this(String.Empty, new List<IChapter>())
        { }

        public Book(string title)
            : this(title, new List<IChapter>())
        { }

        public Book(IEnumerable<IChapter> chapters)
            : this(String.Empty, chapters)
        { }

        public Book(string title, IEnumerable<IChapter> chapters)
        {
            _title = title != null ?
                title : String.Empty;

            _chapters = chapters != null ?
                chapters.ToList() : new List<IChapter>();
        }

        [DataMember]
        public IList<IChapter> Chapters { get { return _chapters; } }

        [DataMember]
        public string Title { get { return _title; } }
    }
}